package com.xiaoxin.nmzp.server.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.nmzp.EduEx;
import com.ruoyi.common.nmzp.ProjectEx;
import com.ruoyi.common.nmzp.WorkEx;
import com.xiaoxin.nmzp.server.entity.domain.NmzpResume;
import com.xiaoxin.nmzp.server.entity.req.ResumeReq;
import com.xiaoxin.nmzp.server.entity.req.SendReq;
import com.xiaoxin.nmzp.server.service.NmzpResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;


@RestController
@RequestMapping("/nmzp/resume")
public class ResumeController {
    @Autowired
    private NmzpResumeService resumeService;

    /**
     * 获取用户简历信息
     */
    @GetMapping
    public AjaxResult getResume(){
        NmzpResume result =  resumeService.getResume();
        return AjaxResult.success(result);
    }

    /**
     * 更新个人优势
     * @param advantage
     * @return
     */
    @PutMapping("/advantage")
    public AjaxResult advantage(@RequestBody @NotBlank(message = "个人优势不能为空！") String advantage){
        resumeService.updateAdvantage(advantage);
        return AjaxResult.success();
    }

    /**
     * 更新工作经历
     * @param workEx
     * @return
     */
    @PutMapping("/workEx")
    public AjaxResult workEx(@RequestBody @Validated WorkEx workEx){
        resumeService.updateWorkEx(workEx);
        return AjaxResult.success();
    }

    /**
     * 更新项目经验
     * @param projectEx
     * @return
     */
    @PutMapping("/projectEx")
    public AjaxResult projectEx(@RequestBody @Validated ProjectEx projectEx){
        resumeService.updateProjectEx(projectEx);
        return AjaxResult.success();
    }

    /**
     * 更新学历信息
     */
    @PutMapping("/eduEx")
    public AjaxResult eduEx(@RequestBody @Validated EduEx eduEx){
        resumeService.updateEduEx(eduEx);
        return AjaxResult.success();
    }

    /**
     * 投递简历
     * @return
     */
    @PostMapping("/toSend")
    public AjaxResult sendResume(@RequestBody SendReq sendReq){
        resumeService.sendResume(sendReq);
        return AjaxResult.success();
    }

}
